<script>
    var _deleteChapter = function(id, el){
        console.log(el);
        if(window.confirm("确定删除这一章节？")){
            $.post("/chapter/delete", {
                id: id
            }).done(function(response){
                        $(el).closest("li.chapter-item").remove();
                        Pinion.simpleNotify("删除成功");
                    });
        }
    }
</script>
<ul class="list-unstyled chapter-list grid">
<#list chapters as chapter>
    <li class="chapter-item">
        <a href="/chapter/${chapter.getInt("id")}">${chapter.getStr("title")}</a>
        <#if book.isAuthor(session['user'])>
            <a class="author-action" onclick="_deleteChapter(${chapter.getInt("id")}, this)" href="javascript: void (0)">删除</a>
            <a class="author-action" href="/chapter/edit/${chapter.getInt("id")}">编辑</a>
        </#if>

        <#--<span class="btn-like action" onclick="Pinion.like('${chapter.class.name}', ${chapter.getInt("id")})">赞</span>&nbsp;&nbsp;&nbsp;&nbsp;-->
        <#--<span class="btn-favorite action" onclick="Pinion.favorite('${chapter.class.name}', ${chapter.getInt("id")})">收藏</span>&nbsp;&nbsp;&nbsp;&nbsp;-->
    </li>
</#list>
<#if book.isAuthor(session['user'])>
    <li><a class="btn btn-default btn-block" href="/chapter/create/${book.id}">添加章节</a></li>
</#if>
</ul>